/* 改动：char数组改为StringBuffer，且没有声明长度。
 * 放弃了运算符重载。指针类型全部改为对象。取消析构函数。
 * spacelength
 */
package com.simulation;

import java.util.ArrayList;
import com.simulation.All.ModelType;

abstract class All {
	static final int NameLenth = 50;
	static final double ZERO = 2.0e-20;
	static final double NormalFiberSpecificHeat = 0.32;
	static final int NX = 5;
	static final int NR = 8;
	static enum ModelType{GasEnergy,AddLiquid,AddPressure,AddVirus,AddNoLocal};

	static final double MembraneWVPX[] = {273.16, 275.66, 283.16, 289.16, 293.16, 318.16};//{0.0, 2.5, 10.0, 16.0, 20.0, 45.0};
	// X-axis for TR curves
	
	static final double MembraneTRX[] = {273.16, 275.66, 283.16, 289.16, 293.16, 318.16};//{0.0, 2.5, 10.0, 16.0, 20.0, 45.0};

	static final double MembraneWVPY[][] = {
	/*0--OP--Open structure*/{1e+8, 1e+8, 1e+8, 1e+8, 1e+8, 1e+8},
	/*1--CV--Cotton Ventile*/{320, 500, 600, 720, 860, 1547},
	/*2--DX--Diaplax Membrane*/{1500, 2000, 6700, 10000, 10500, 10250},
	/*3--HP--Hydrophilic Laminated*/{180, 300, 400, 440, 500, 931},
	/*4--MF--Microfibre fabrics*/{330, 540, 670, 770, 880, 1606},
	/*5--PP--Poromeric Polyurethane-laminated*/{180, 350, 460, 520, 550, 1072},
	/*6--PTFE--PTFE-laminated*/{220, 430, 550, 640, 730, 1410},
	/*7--PU--Polyurethane-coated*/{70, 100, 150, 180, 240, 452},
	/*8--WPBF--Undefined*/{0.0, 6.0, 10.0, 14.0, 20.0, 45.0}};
	
	static final double MembraneTRY[][] = {
			/*0--OP--Open structure*/{0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
			/*1--CV--Cotton Ventile*/{0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
			/*2--DX--Diaplax Membrane*/{0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
			/*3--HP--Hydrophilic Laminated*/{0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
			/*4--MF--Microfibre fabrics*/{0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
			/*5--PP--Poromeric Polyurethane-laminated*/{0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
			/*6--PTFE--PTFE-laminated*/{0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
			/*7--PU--Polyurethane-coated*/{4.18e+3, 4.18e+3, 4.18e+3, 4.18e+3, 4.18e+3, 4.18e+3},
			/*8--WPBF--Undefined*/{0.0, 0.0, 0.0, 0.0, 0.0, 0.0}};
	
	static final double PCMPROPERTY[]={5.0e-4,0.779,0.000717,0.000956,238.76*0.239,0.01195,28.0+273.16};
}

/*************************************** Boundary condition definition ******************************************/
class BoundaryHuman
{
	int m_metabolicRate;
	double m_heatCoeUncover;
	double m_heatCoeCover;
	double m_radCoeUncover;
	double m_radCoeCover;
};

class BoundaryEnv
{
	double m_temperature;
	double m_radiation;
	double m_humidity;
	double m_liquidFraction;
	double m_velocity;
};

class BoundaryFabric
{
	int  m_indexFabric;
	boolean m_innerContact;
	boolean m_outerContact;
	double m_heatCoeInner;
	double m_heatCoeOuter;
	double m_massCoeInner;
	double m_massCoeOuter;
	double m_evapCoe;
	float m_iMassPumpingRation;
	float m_iHeatPumpingRation;
	
	BoundaryFabric() {
		//m_innerContact = true;
		//m_outerContact = true;
		m_heatCoeInner = 13.7;
		m_heatCoeOuter = 13.7;
		m_massCoeInner = 0.019359;
		m_massCoeOuter = 0.019359;
		m_evapCoe = 13.7;
		m_iMassPumpingRation = 0;
		m_iHeatPumpingRation = 0;
	}
};

class BoundarySeg
{
	String m_stageName;
	int m_segment;
	BoundaryHuman m_BHuman = new BoundaryHuman();
	BoundaryEnv m_BEnv = new BoundaryEnv();
	ArrayList<BoundaryFabric> m_Bfabric = new ArrayList<BoundaryFabric>();
	
	BoundarySeg() {
		m_BHuman.m_metabolicRate = 165;
		m_BHuman.m_heatCoeUncover = 0.000239;
		m_BHuman.m_heatCoeCover = 0.000239;
		m_BHuman.m_radCoeUncover = 0.0001434;
		m_BHuman.m_radCoeCover = 0.0001434;
		m_BEnv.m_temperature = 30;
		m_BEnv.m_radiation = 0;
		m_BEnv.m_humidity = 50;
		m_BEnv.m_liquidFraction = 2e-020;
		m_BEnv.m_velocity = 3.5;
	}
};
/********************************************** End of boundary condition definition **********************************/

class ModelSelection
{
	boolean localTemperature;
	boolean nonLocalTemperature;
	boolean liquid;
	boolean wateVapor;
	boolean pressure;
	boolean virus;
	boolean membrane;
	boolean PCM;
	boolean selfHeating;
	boolean radiation;
	boolean bodyModel;
	boolean babyModel;
	boolean comfort;
};

class TwoElementArray
{
	double preNodeValue;
	double nextNodeValue;
};

class FiberType
{
	String FiberName;
	double Diameter;
	double Density;
	double Emissivity;
	double VaporDiff;
	double LiqConAngle;
	double FiberRegainY[] = new double[16];
	double FiberRegainX[] = new double[16];
};

class PCMType
{
	StringBuffer PCMName;
	double Radius;
	double Density;
	double K_ml;
	double K_ms;
	double Ramda_m;//LatentHeatPCM
	double T_p; //MeltingTemperature
	double h_T; //HeatTransferCoe
};

class  MembraneType
{
	StringBuffer MembraneName;
	double Thickness;
	ArrayList<Double> WVPY;
	ArrayList<Double> WVPX;
	ArrayList<Double> TRX;
	ArrayList<Double> TRYY;
	double WVP;
	double TR;
	double WR;
};

class FabricType
{
	String FabricName;
	double VolumePercenFiber;
	double VolumePercentPCM;
	double TortuosGas;
	double Thickness;
	double CapAngle;
	double TortuosLqd;
	double MaxDisCapDia;
	double Emissivity;
	double porosity;
	double ContactAngle;

	ArrayList <FiberType> FiberList;
	ArrayList <Double> MassRatio;
	MembraneType OuterMembrane;
	MembraneType InnerMembrane;
	PCMType PCM;
	boolean SelfHeat;
	
	FabricType() {
		MassRatio = new ArrayList<Double>();
		FiberList = new ArrayList<FiberType>();
		InnerMembrane = null;
		OuterMembrane = null;
		PCM = null;
		//FabricName = "Name";
		//Thickness = 0;
		VolumePercenFiber = 0.12;
		VolumePercentPCM = -4.8367e-026;
		TortuosGas = 1.2;
		CapAngle = 20;
		TortuosLqd = 1.2;
		MaxDisCapDia = 0.12;
		SelfHeat = false;
		porosity = 0.85;
		ContactAngle = 70;
		Emissivity = 0.9;
	}
};

class SourceType
{
	boolean Radiation;
	boolean PCM;
	boolean SelfHeating;
};

class SelfHeatType
{
	boolean HasSet;
	double HeatTemperature;
	double CoolTemperature;
	double HeatGot;
	double HeatLoss;
	//SelfHeatType *operator=(SelfHeatType *selfHeat);
};

class VirusType
{
	boolean HasSet;
	double Density;
	double MaxVelocityBreathOut;
	double RadiusVirusParticle;
	double RatioAreaNares;
	double EffectiveCoeCapture;
	double RetentionEfficiency;
	double AdjustableParameter;
	double CriticalVelocity;
	double ReleaseCoeVirus;
	double BrownCoe;
	//VirusType *operator=(VirusType *virus);
};

class GasType
{
	double Density;
	double HeatCapacity;
	double DynamicViscosity; /* mu(s) */
	double MoleMass; /* Mg */
	double GasConstant; /* R */
	double DiffusionCoeWaterVapor;
	double PHeatCapacityVapor; /* Cp,a*/
	double PHeatCapacityDryAir; /* Cp,d */
	double ThermoConductivity; /* Kvg*/
	double CoeHeatChange;
	boolean HasSet;
	//GasType *operator=(GasType *gas);
};

class LiquidType
{
	double HeatEvaporation;
	double Density; /* rho(l)*/
	double HeatCapacity; /* Cvl*/
	double ThermoConductivity; /* Kvl*/
	double DynamicViscosity; /* mu(l)*/
	double SurfaceTension; /*sigma*/
	double MoleMass; /* Mw */
	boolean HasSet;
	//LiquidType *operator=(LiquidType *liquid);
};

class GarmentType
{
	String GarmentName;
	ArrayList<Integer> FabricList; // store the number of the fabric in the fabric list
	VirusType Virus;
	SelfHeatType SelfHeat;
	GasType Gas;
	LiquidType Liquid;
	ModelType modelFlag;
	SourceType sourceItem;
	String[] fabricname = new String[3];
	//double m_coverRatio[6];
	
	GarmentType() {
		FabricList = new ArrayList<Integer>();
		sourceItem = new SourceType();
		Virus = null;
		SelfHeat = null;
		GarmentName = "Name";
		modelFlag = ModelType.AddPressure;
		sourceItem.Radiation = false;
		sourceItem.PCM = true;
		sourceItem.SelfHeating = false;
		
		Gas = new GasType();
		Gas.Density = 0.0011614;
		Gas.HeatCapacity = 1.197;
		Gas.DynamicViscosity = 0.000183;
		Gas.MoleMass = 29;
		Gas.GasConstant = 8.31e+007;
		Gas.DiffusionCoeWaterVapor = 0.25;
		Gas.PHeatCapacityVapor = 0.48039;
		Gas.PHeatCapacityDryAir = 0.240195;
		Gas.ThermoConductivity = 6.1901e-005;
		Gas.CoeHeatChange = 0.000816;
		
		Liquid = new LiquidType();
		Liquid.Density = 1;
		Liquid.HeatEvaporation = 13.7;
		Liquid.HeatCapacity = 1;
		Liquid.ThermoConductivity = 0.001434;
		Liquid.DynamicViscosity = 0.01003;
		Liquid.SurfaceTension = 31;
		Liquid.MoleMass = 18;
	}
};

class GarmentRecord
{
	boolean PartsWithGarment[] = new boolean[6];
	int FirstPosition[] = new int[6];
};

class GarmentParts
{
	double coverRatio[] = new double[6];
	String[] garmentName = new String[6];
	String[] fabricIndex = new String[3];
	String garmentId;

	int m_iSelectedGarmentInList;
	
	GarmentParts() {
		garmentId = "GarmentId";
		m_iSelectedGarmentInList = 2;
		for(int i=0; i<6; i++) {
			coverRatio[i] = 0.0;
			//garmentName[i] = "";
		}
	}
};


class BodyType
{  
	double C[] = new double[25];
	double QB[] = new double[24];
	double EB[] = new double[24];
	double BFB[] = new double[24];
	double TC[] = new double[24];
	double TSET[] = new double[25];
	double T[] = new double[25];
	double S[] = new double[6];
	double HC[] = new double[6];
	double SKINR[] = new double[6];
	double SKINS[] = new double[6];
	double SKINV[] = new double[6];
	double SKINC[] = new double[6];
	double MWORK[] = new double[6];
	double MCHILL[] = new double[6];
	double CCON;
	double SCON;
	double PCON;
	double Res ;
	double CCHIL ;
	double PCHIL ;
	double SCHIL ;
	double CSW ;
	double SSW ;
	double CDIL ;
	double PSW ;
	double SDIL ;
	double PDIL ;
	int m_gender;
	int m_age;
	String m_nation;
	double m_breast;
	String m_BreastUnit;
	double m_waist;
	String m_WaistUnit;
	double m_hip;
	String m_HipUnit;
	String m_modelId;
	String m_sizeClass;
	String m_size;
};

class StageType
{
	double InTemperature;
	double OutTemperatrue;
	double InRH;
	double OutRH;
	double InVelocity;
	double OutVelocity;
	double InWater;
	double OutWater;
	double InPressure;
	double OutPressure;
	double InVirus;
	double OutVirus;
	double RadiationConstant;
	ArrayList<Double>[] SpaceLength = new ArrayList[6];// double type
	ArrayList<BoundarySeg> Boundary;
	int BodyGarment[] = new int[6];
	double AirThickness;
	double Work;
	double Time;
	double BabyCoverage[] = new double[4];  

	String StageName;
	String weather;
	boolean isDefAll;
	
	StageType() {
		for(int i=0; i<6; i++) {
			SpaceLength[i] = new ArrayList<Double>();
		}
		StageName = "stage";
		OutTemperatrue = 293.16;
		InTemperature = 30;
		OutRH = 0.6;
		InRH = 50;
		InVelocity = 3.5;
		OutVelocity = 0.1;
		InWater = 0.001;
		OutWater = 0.001;
		InPressure = 101325;
		OutPressure = 101325;
		InVirus = 0;
		OutVirus = 0;
		RadiationConstant = -4.8367e-026;
		Work = 165;
		Time = 25;
		weather = "Sunny";
		isDefAll = true;
	}
};

class ControlType
{
	double TimeStep;
	double SaveFrequency;
	double FabricGrid;
	double FiberGrid;
	double InitialT;
	double InitialRH;
	double InitialP;
	double InitialWater;
	double VirusInitial;
};
